package com.atguigu.tingshu.album.api;

import com.atguigu.tingshu.album.service.BaseAttributeService;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.model.album.BaseAttribute;
import com.atguigu.tingshu.model.album.BaseCategory3;
import com.atguigu.tingshu.model.album.BaseCategoryView;
import com.atguigu.tingshu.vo.album.AlbumCategoryVo;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value = "/api/album/category")
@SuppressWarnings({"unchecked", "rawtypes"})
public class BaseCategoryApiController {

    @Autowired
    private BaseCategoryService baseCategoryService;

    @Autowired
    private BaseAttributeService baseAttributeService;


    ///api/album/category/getBaseCategoryList
    //查询所有分类数据
    @GetMapping(value = "getBaseCategoryList")
    public Result<List<AlbumCategoryVo>> findAllCategory() {
        List<AlbumCategoryVo> categoryVoList = baseCategoryService.findAllCategory();
        return Result.ok(categoryVoList);
    }



    //	/api/album/category/findAttribute/{category1Id}
    //根据一级分类Id查询专辑属性
    @GetMapping(value = "findAttribute/{category1Id}")
    public Result<List<BaseAttribute>> findAttribute(@PathVariable(value = "category1Id") Long category1Id) {
        List<BaseAttribute> baseAttributeList = baseAttributeService.findAttribute(category1Id);
        return Result.ok(baseAttributeList);
    }


    //根据三级分类Id查询专辑属性
    @GetMapping(value = "/categoryfindAttribute/{category3Id}")
    public Result<BaseCategoryView> categoryfindAttribute(@PathVariable Long category3Id) {
        BaseCategoryView baseCategoryView = baseCategoryService.findCategoryByCategory3Id(category3Id);
        return Result.ok(baseCategoryView);
    }



    // /api/album/category/getBaseCategoryList/{category1Id}
    //根据一级分类id获取全部分类信息
    @GetMapping("getBaseCategoryList/{category1Id}")
    public Result<AlbumCategoryVo> getCategoryList(@PathVariable Long category1Id) {

        AlbumCategoryVo albumCategoryVo = baseCategoryService.getCategoryList(category1Id);
        return Result.ok(albumCategoryVo);
    }



    // /api/album/category/findTopBaseCategory3/{category1Id}
    //根据一级分类id查询置顶三级分类
    @GetMapping("findTopBaseCategory3/{category1Id}")
    public Result<List<BaseCategory3>> findTopBaseCategory3(@PathVariable Long category1Id) {
        List<BaseCategory3> baseCategory3List = baseCategoryService.findTopBaseCategory3(category1Id);
        return Result.ok(baseCategory3List);
    }
}

